package com.example.yangyinzhaixian.Fragemt;


import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yangyinzhaixian.R;
import com.example.yangyinzhaixian.uitl.SharedPreferencesUtils;
import com.example.yangyinzhaixian.widget.media.IRenderView;
import com.example.yangyinzhaixian.widget.media.IjkVideoView;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONException;

import okhttp3.Call;

/**
 * A simple {@link Fragment} subclass.
 */
public class MineFragment extends Fragment implements View.OnClickListener {


    private View inflate;
    private ImageView imageView5;
    private ImageView imageView6;
    private TextView textView9;
    private Button button3;
    private IjkVideoView video_view;
    private ImageView imageView7;
    private TextView textView10;
    private ImageView imageView8;
    private Button button2;

    public MineFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        inflate = inflater.inflate(R.layout.fragment_two, container, false);
        initView(inflate);
        String token = (String) SharedPreferencesUtils.getParam(getActivity(), "Token", "");
        OkHttpUtils.get().url("http://api.immedc.com/restapi/my/checkIsStatus")
                .addHeader("CH-TOKEN", token).build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(String response, int id) throws JSONException {
                Log.i("TagA", "token:" + response);
            }
        });

        imageView7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView7.setVisibility(View.GONE);
                video_view.setAspectRatio(IRenderView.AR_ASPECT_FIT_PARENT);
                video_view.setVideoURI(Uri.parse("http://1251603248.vod2.myqcloud.com/4c9adaa7vodtransgzp1251603248/472f6f529031868222888465148/f0.f40.mp4"));
                video_view.start();
            }
        });
        return inflate;

    }
    private void initView(View inflate) {
        imageView5 = (ImageView) inflate.findViewById(R.id.imageView5);
        imageView6 = (ImageView) inflate.findViewById(R.id.imageView6);
        textView9 = (TextView) inflate.findViewById(R.id.textView9);
        button3 = (Button) inflate.findViewById(R.id.button3);
        video_view = (IjkVideoView) inflate.findViewById(R.id.video_view);
        imageView7 = (ImageView) inflate.findViewById(R.id.imageView7);
        textView10 = (TextView) inflate.findViewById(R.id.textView10);
        imageView8 = (ImageView) inflate.findViewById(R.id.imageView8);
        button2 = (Button) inflate.findViewById(R.id.button2);
        button3.setOnClickListener(this);
        button2.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button3:

                break;
            case R.id.button2:

                break;
        }
    }
}
